from django.contrib import admin

from .models import Game
from .models import TestDetail
from .models import YDProject
from .models import YDGame


class GameAdmin(admin.ModelAdmin):
    list_display = ('name', 'game_type', 'client_id')
    list_filter = ('game_type',)
    search_fields = ('client_id', 'name')


class TestDetailAdmin(admin.ModelAdmin):
    list_display = (
    'game', 'appver', 'pt_type', 'recharge', 'creator', 'add_date', 'result')
    list_filter = ('creator',)
    ordering = ('-add_date',)

class YDGameAdmin(admin.ModelAdmin):
    list_display = ('project_id','game','client_id')
    list_filter = ['project_id']
    search_fields = ('client_id', 'game')

    def client_id(self,obj):
        return u'%s' % obj.game.client_id




class YDGmaeInline(admin.TabularInline):
    model = YDGame
    extra = 0

class YDProjectAdmin(admin.ModelAdmin):
    list_display = ('project_name','project_id')
    inlines = [YDGmaeInline]

admin.site.register(Game, GameAdmin)
admin.site.register(TestDetail, TestDetailAdmin)
admin.site.register(YDProject,YDProjectAdmin)
admin.site.register(YDGame,YDGameAdmin)